import { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import styles from './index.module.scss'
import classNames from 'classnames'
// import './index.scss'

export default class GoodsPrice extends Component {
  props: any
  render () {
    const prefixCls = 'goods-price'
    const { goods={}, sale, origin, isSku, saleSize=32, originSize=20, className } = this.props
    const info = Object.assign({ isSku, salePrice: sale, originPrice: origin }, goods)
    return (
      <View className={classNames(styles[prefixCls], className)}>
        <View className={styles[`${prefixCls}__sale`]}>
          <View className={classNames(styles[`${prefixCls}__sale-unit`], `f-s-${originSize}`)}>￥</View>
          <View className={classNames(styles[`${prefixCls}__sale-num`], `f-s-${saleSize}`)} >{info.salePrice}</View>
          {!!info.isSku && <View className={`${prefixCls}__sale-text`}>起</View>}
        </View>
        {info.originPrice > info.salePrice && !info.isSku && <View className={classNames(styles[`${prefixCls}__origin`], `f-s-${originSize}`)}>￥{info.originPrice}</View>}
      </View>
    )
  }
}
